﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Common
{
    public class TextFilter
    {
        private static string[] ribbishkeywords;
        public static string[] RubbishKeyWords
        {
            get
            {
                if (ribbishkeywords == null)
                {
                    string keywords = Utility.FileString("rubbishkw.kw");
                    if (!string.IsNullOrEmpty(keywords))
                    {
                        ribbishkeywords = keywords.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    }
                }
                return ribbishkeywords;
            }
        }

        /// <summary>
        /// 是否为垃圾文件
        /// </summary>
        /// <param name="v"></param>
        /// <returns></returns>
        public static bool IsRibbishFile(string v)
        {
            foreach (string item in RubbishKeyWords)
            {
                if (v.IndexOf(item)!=-1)
                {
                    return true;
                }
            }
            return false;
        }

    }
}
